import sympy as sp
from sympy import limit, oo  # oo表示无穷大

# 定义符号变量
x = sp.symbols('x')

# 基本极限
lim1 = limit(1/x, x, oo)
print("极限1:", lim1)  # 极限1: 0

# 重要极限
lim2 = limit((1 + 1/x)**x, x, oo)
print("极限2:", lim2)  # 极限2: E

# 左极限和右极限
lim_left = limit(1/x, x, 0, '-')  # 从负方向逼近
lim_right = limit(1/x, x, 0, '+')  # 从正方向逼近
print("左极限:", lim_left)  # 左极限: -oo
print("右极限:", lim_right) # 右极限: oo